import DateUtil from '@/utils/date';

export default {
  formatDate(time) {
    if (time != null && time != undefined && time != '') {
      let date = new Date(time.substring(0,10));
      return DateUtil.parseTime(date, '{y}-{m}-{d}');
    }
  },

 // formatTimestamp(time) {
  formatTimestamp(time){
    if (time != undefined && time != null) {
      let date=time.replace(new RegExp(/-/gm) ,"/");
      date = new Date(date);
      return DateUtil.parseTime(date, '{y}-{m}-{d} {h}:{i}:{s}');
    }
  },
  formatYearMonth(time) {
    if (time != null && time != undefined && time != '') {
      let date = new Date(time.substring(0,10));
      return DateUtil.parseTime(date, '{y}年{m}月');
    }
  },
  formatPrice(data) {
    if (data != null && data != undefined && data != '') {
      return parseFloat(data).toFixed(2);
    }
  },
}
